<template>
  <div class="about">
    <van-cell-group inset>
      <van-field label="文章标题" v-model="title" placeholder="请输入标题" />
      <van-field label="内容" v-model="content" placeholder="请输入内容" />
      <van-field name="switch" label="开关">
        <template #input>
          <van-switch v-model="status" />
        </template>
      </van-field>
    </van-cell-group>
    <button @click="save">发布</button>
    <button>重置</button>
  </div>
</template>
<script>
import { ref } from "vue";
import http from "@/utils/http";
export default {
  data() {
    return {
      title: "",
      content: "",
      status: "",
    };
  },
  setup() {
    const value = ref("");
    return { value };
  },
  setup() {
    const checked = ref(false);
    return { checked };
  },
  methods: {
    async save() {
      console.log(this.title);
      let r = await http({
        method: "post",
        url: "/posts",
        data: {
          title: this.title,
          content: this.content,
          status: this.status,
        },
      });
      this.title = "";
      this.content = "";
      this.status = "";
    },
  },
};
</script>
<style></style>
